﻿using MediatR;
using RBAC.Domain;
using RBAC.Domain.Service.Interfae;
using RBACDuYaJun.Api.Appliction.Command.LeaveCommand;
using System.Security.Cryptography;

namespace RBACDuYaJun.Api.Appliction.CommandHandlers.LeaveHanders
{
    public class LeaveCreateCommandHabdler : IRequestHandler<LeaveCreateCommand, int>
    {
        private readonly ILeaveService _leaveService;
        public LeaveCreateCommandHabdler(ILeaveService leaveService)
        {
            _leaveService = leaveService;
        }

        public async Task<int> Handle(LeaveCreateCommand request, CancellationToken cancellationToken)
        {
            return await _leaveService.AddLeave(new Leave()
            {
                LeaveId = request.LeaveId,
                LeaveName = request.LeaveName,
                Pid = request.Pid,
                LeaveType = request.LeaveType,
                LeaveSdate = request.LeaveSdate,
                LeaveEdate = request.LeaveEdate,
                DateNum = request.DateNum,
                ComeDate = request.ComeDate,
                LeaveReason = request.LeaveReason,
                Rolenames = request.Rolenames,
                addName = "张三",
                addDate = DateTime.Now,
            });
        }
    }
}
